#include "desktop.h"

BeginPage* begin_page;
MainPage* main_page;
ControlPage* control_page;
AppsPage* apps_page;

void desktop_init(void)
{

  begin_page = new BeginPage();
  main_page = new MainPage();
  control_page = new ControlPage();
  apps_page = new AppsPage();

  main_page->show();

  // apps_page->show();

  // control_page->show();

  // MainPage 
  lv_obj_add_event_cb(main_page->get_lv_obj_t(), [](lv_event_t* e) {

    lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());

    if (dir == LV_DIR_BOTTOM) { // 下滑为控制中心

      // control_page->show();
      // lv_scre
      // lv_disp_
      lv_scr_load_anim(control_page->get_lv_obj_t(), LV_SCR_LOAD_ANIM_OVER_BOTTOM, 500, 0, false);

      return;
    }

    if (dir == LV_DIR_TOP) { // 上滑为

      // main_page->show();

      return;
    }
    if (dir == LV_DIR_RIGHT) { // 右滑为

      // main_page->show();

      return;
    }

    if (dir == LV_DIR_LEFT) { // 左滑为应用列表页


      // apps_page->show();
      lv_scr_load_anim(apps_page->get_lv_obj_t(), LV_SCR_LOAD_ANIM_MOVE_LEFT, 500, 0, false);

      return;
    }

    }, LV_EVENT_GESTURE, NULL);


  // control_page
  lv_obj_add_event_cb(control_page->get_lv_obj_t(), [](lv_event_t* e) {

    lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());

    if (dir == LV_DIR_TOP) { // 下滑为控制中心

      // main_page->show();
      lv_scr_load_anim(main_page->get_lv_obj_t(), LV_SCR_LOAD_ANIM_FADE_ON, 300, 0, false);

      return;
    }

    }, LV_EVENT_GESTURE, NULL);




  lv_obj_add_event_cb(apps_page->get_lv_obj_t(), [](lv_event_t* e) {

    lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());

    if (dir == LV_DIR_RIGHT) {

      // main_page->show();

      lv_scr_load_anim(main_page->get_lv_obj_t(), LV_SCR_LOAD_ANIM_OVER_RIGHT, 500, 0, false);
      return;
    }

    }, LV_EVENT_GESTURE, NULL);






}